class Solution {
    public int removeDuplicates(int[] nums) {
        int length = nums.length;
        int quick = 1, slow = 0;

        for (; quick < nums.length; quick++) {
            if (nums[slow] == nums[quick]) {
                length--;
            } else {
                nums[++slow] = nums[quick];
            }
        }
        return length;
    }
}